package com.zzh.net.Utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by 玉金 on 2016/3/9 0009.
 * 获取PackageInfo
 */
public class PackInfoUtils {

    public static int getVersionCode()//获取版本号(内部识别号)
    {
        try {
            PackageInfo pi = NetUtil.mContext.getPackageManager().getPackageInfo(NetUtil.mContext.getPackageName(), 0);
            return pi.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return 0;
        }
    }

    public static String getVersion()//获取版本号
    {
        try {
            PackageInfo pi = NetUtil.mContext.getPackageManager().getPackageInfo(NetUtil.mContext.getPackageName(), 0);
            return pi.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "";
        }
    }

}
